<?php
class Currency extends AppModel
{
    var $name = 'Currency';
    var $displayField = 'name';
    //$validate set in __construct for multi-language support    
    function __construct($id = false, $table = null, $ds = null)
    {
        parent::__construct($id, $table, $ds);
        $this->validate = array(
            'name' => array(
                'rule' => 'notempty',
                'allowEmpty' => false,
                'message' => __l('Required')
            ) ,
            'code' => array(
                'rule' => 'notempty',
                'allowEmpty' => false,
                'message' => __l('Required')
            ) ,
            'symbol' => array(
                'rule' => 'notempty',
                'allowEmpty' => false,
                'message' => __l('Required')
            )
        );        
    }
	function cacheCurrency(){
		$currencies = $this->find('all', array(
			'conditions' => array(                    
				'Currency.is_enabled' => 1
			),     
			'fields' => array(
				'Currency.id',
				'Currency.name',
				'Currency.code',
				'Currency.symbol',	
				'Currency.dec_point',	
				'Currency.thousands_sep',									
			),           
			'order' => array(
				'Currency.id' => 'ASC'
			)
		));            
		Cache::write('site_currencies', $currencies);
		return $currencies;
	}
	function afterSave() {
        Cache::delete('site_currencies');
    }
    function afterDelete() {
        Cache::delete('site_currencies');
    }
}
?>